package com.j.lemon.learn.utils;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MemoryLeakClass {
    private ScheduledExecutorService THREAD = Executors.newScheduledThreadPool(1);
    private ConcurrentHashMap<String,Object> customerPermission = new ConcurrentHashMap<>();
    public MemoryLeakClass() {
    }
    public void aaa(){
        THREAD.scheduleAtFixedRate(new Runnable() {

            @Override
            public void run() {
                ConcurrentHashMap<String,Object> map = new ConcurrentHashMap<>();
                for (int i = 0; i < 1000000; i++) {
                    map.put("123123123123123123123123123123123123123"+i,0);
                }
                System.out.println("put done");
                customerPermission = map;
            }
        },0,1, TimeUnit.SECONDS);
        while (true){
            Object o = customerPermission.get("1231231231231231231231231231231231231231");
            if(o==null){
                System.out.println("null");
            }
        }

    }
}
